window.onload = function(){
	var myScroll = new IScroll('#wrapper', {
	    mouseWheel: true,
	    scrollbars: false
	});
	console.log(myScroll);
}
$(function(){
	chakan();
	$('.del').on('tap',function(){
		layer.open({
		    title: [
		      '温馨提示',
		      'background-color: #4990E2; color:#fff;'
		    ],
		    shadeClose:false
		    ,content: '<div class="data-cont">'+
			    			 '<p>是否要删除这条公告？</p>'+
			    		     '<div class="anniu">'+
				    		     '<a class="cancel mui-pull-left" href="javascript:;">取消</a>'+
				    		     '<span class="anniu-line"></span>'+
				    		     '<a class="confirm mui-pull-right" href="javascript:;">确定</a>'+
			    		     '</div>'+
			    		  '</div>'
		  });
		  $('.cancel').on('tap',function(){
			  	$(".layui-m-layer0").css({opacity:'0'});
				setTimeout(function(){
					var index = $('.layui-m-layer0').attr('index');
					layer.close(index);
				},500);
			})
			$('.confirm').on('tap',function(){
				var $id = $(".del").attr('dataid');
                $.post('/index/del/news',{id:$id},function (data) {
                    if(data.code==200){
                        mui.alert(data.msg);
                        var index = $('.layui-m-layer0').attr('index');
                        layer.close(index);
                        setTimeout(function(){
                            window.location.href = '/index/index/coremsg';
                        },2000);
                    }else{
                        mui.alert(data.msg);
                    }
                });
			  	// setTimeout(function(){
			  	// 	window.location.href = 'index.html';
				// 	var index = $('.layui-m-layer0').attr('index');
				// 	layer.close(index);
				// },500);
			})
	});
	
	
	$('.agree').on('tap',function(){
		var $id = $(this).attr('dataid');
		// console.log($id);
		$.post("/index/api/leave",{id:$id,type:'同意'},function (data) {
            console.log(data);
			if(data.code==200){
                mui.alert(data.msg);
                setTimeout(function () {
					window.location.reload();
                },2000)
			}else{
                mui.alert(data.msg);
			}
        });
		// var step = $('.examine-step').eq(1);
		// var time = $('.examine-time').eq(1);
		// step.removeClass('approval');
		// step.addClass('complete');
		// step.text('已同意');
		// time.text('2018年05月22日 08:20');
		// chakan();
	});
	$('.reject').on('tap',function(){
        var $id = $(this).attr('dataid');
        // console.log($id);
        $.post("/index/api/leave",{id:$id,type:'驳回'},function (data) {
        	console.log(data);
            if(data.code==200){
                mui.alert(data.msg);
                setTimeout(function () {
                    window.location.reload();
                },2000)
            }else{
                mui.alert(data.msg);
            }
        });
		// var step = $('.examine-step').eq(1);
		// var time = $('.examine-time').eq(1);
		// step.removeClass('approval');
		// step.addClass('rebut');
		// step.text('已驳回');
		// time.text('2018年05月22日 08:20');
		// chakan();
	})
	
	function chakan(){
		$.each($('.examine-row'), function(i,v) {
			var step = $(v).find('.examine-step');
			if(($(step).is('.sendOut') || $(step).is('.complete')) && i != 2){
				$(v).find('.examine-line').show();
			}
		});
	}
})
